package com.mytest.example.gobrs.task.chain6;

import com.gobrs.async.TaskSupport;
import com.gobrs.async.anno.Task;
import com.gobrs.async.task.AsyncTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


@Slf4j
@Task(failSubExec = true)
@Component
public class Chain6TaskB extends AsyncTask<Chain6Param1, String> {
    @Override
    public void prepare(Chain6Param1 o) {

    }

    @Override
    public String task(Chain6Param1 o, TaskSupport taskSupport) {
        String chain = o.getChain() + "->Chain6TaskB ";
        o.setChain(chain);
        return "Chain6TaskB";
    }

    @Override
    public boolean nessary(Chain6Param1 o, TaskSupport taskSupport) {
        //判断当前task 是否需要执行 如果返回true 则需要被执行，否则返之
        return true;
    }

    @Override
    public void onSuccess(TaskSupport taskSupport) {
        log.info("Chain6TaskB 执行完成");

    }

    @Override
    public void onFail(TaskSupport taskSupport) {
        log.error("Chain6TaskB 执行失败");
    }
}
